/**
 * DaoXzqh.java
 *2013年10月6日下午2:26:09
 *LINKT
 */
package com.jskj.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.jskj.bean.Xzqh;
import com.jskj.commons.DBConn;

/**
 * @author LINKT
 *
 */
public class DaoXzqh {

        
        public Xzqh  getXzqhforDm(String xzqh_dm) {
                Xzqh x=new Xzqh();
                DBConn conn=new DBConn();
                ResultSet rs=conn.SelectSQL("select * from xzqh where xzqh_dm='"+xzqh_dm+"'");
                try {
                        if (rs.next()) {
                                x.setXzqh_dm(rs.getString("xzqh_dm"));
                                x.setXzqh_mc(rs.getString("xzqh_mc"));
                                x.setXzqh_sj_dm(rs.getString("xzqh_sj_dm"));
                                x.setLeaf(rs.getString("leaf"));
                        }
                        rs.close();
                        conn.Close();
                } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                return x;
        }
        /**
         * 
         * @param xzqh_sj_dm
         * @return
         */
        public String getXzqhList(String xzqh_dm){
                DBConn conn=new DBConn();
                ResultSet rs=conn.SelectSQL("select * from xzqh where xzqh_sj_dm='"+xzqh_dm+"'");
                StringBuffer sb=new StringBuffer();
                try {
                        while (rs.next()) {
                                sb.append("{\"id\":\""+rs.getString("xzqh_dm")+"\",\"text\":\""+rs.getString("xzqh_mc")+"\",\"leaf\":\""+rs.getString("leaf")+"\"},");
                        }
                        rs.close();
                        conn.Close();
                        if (sb.length()>0) {
                                sb=sb.deleteCharAt(sb.length()-1);
                        }
                } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                return "["+sb.toString()+"]";
        }
        public String getXzqhListNoLeaf(String xzqh_dm){
                DBConn conn=new DBConn();
                ResultSet rs=conn.SelectSQL("select * from xzqh where xzqh_sj_dm='"+xzqh_dm+"'");
                StringBuffer sb=new StringBuffer();
                try {
                        while (rs.next()) {
                                sb.append("{\"id\":\""+rs.getString("xzqh_dm")+"\",\"text\":\""+rs.getString("xzqh_mc")+"\"},");
                        }
                        rs.close();
                        conn.Close();
                        if (sb.length()>0) {
                                sb=sb.deleteCharAt(sb.length()-1);
                        }
                } catch (SQLException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                return "["+sb.toString()+"]";
        }
}
